import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int[] ar = new int[100001];
        int Min = 0;
        int Max = 0;
        int ans1 = 0;
        int ans2 = 0;
        while(scanner.hasNext()) {
            int x = scanner.nextInt();
            if(Min > x) {
                Min = x;
            }
            if(Max < x) {
                Max = x;
            }
            ar[x]++;
        }
        for (int i = Min; i < Max; i++) {
            if(ar[i] == 2) {
                ans1 = i;
            }
            if(ar[i] == 0) {
                ans2 = i;
            }
            if(ans1 != 0 && ans2 != 0) {
                System.out.println(ans1 + " " + ans2);
                break;
            }
        }
    }
}
